#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

int main()
{
	int n = 0, m = 0;
	cin >> n >> m;
	vector<vector<int>> segs;
	segs.push_back({ -1, -1, -1 });

	for (int i = 1, l = 0, r = 0; i <= n; i++) {
		cin >> l >> r;
		if (l > r) {
			r += m;
		}
		segs.push_back({ i, l, r });
		segs.push_back({ i, l + m, r + m });
	}
	sort(segs.begin(), segs.end(), [](auto a, auto b) { return a[1] < b[1]; });

	int power = log2(segs.size());
	int e = n << 1;
	vector<vector<int>> st(e + 1, vector<int>(power + 1, 0));

	for (int i = 1, over = 1; i <= e; i++) {
		while (over + 1 <= e && segs[over + 1][1] <= segs[i][2]) {
			over++;
		}
		st[i][0] = over;
	}

	for (int p = 1; p <= power; p++) {
		for (int i = 1; i <= e; i++) {
			st[i][p] = st[st[i][p - 1]][p - 1];
		}
	}

	vector<int> ans(n + 1);
	for (int i = 1; i <= n; i++) {
		int aim = segs[i][1] + m, cur = i, next, steps = 1;
		for (int p = power; p >= 0; p--) {
			next = st[cur][p];
			if (segs[next][2] < aim) {
				steps += 1 << p;
				cur = next;
			}
		}
		ans[segs[i][0]] = steps + 1;
	}

	for (int i = 1; i <= n; i++) {
		cout << ans[i] << ' ';
	}
	cout << endl;

	return 0;
}